package com.glodon.paas.document.dao.domain;

import java.util.ArrayList;
import java.util.List;

import com.glodon.paas.document.api.bean.File;
import com.glodon.paas.storage.Part;
import com.google.code.morphia.annotations.Entity;
import com.google.code.morphia.annotations.Id;

@Entity(value = "part", noClassnameStored = true)
public class PartEntity {

    public static Part getDto(PartEntity e) {
        if (e == null) {
            return null;
        } else {
            Part d = new Part();
            d.setETag(e.getETag());
            d.setIndex(e.getIndex());
            d.setKey(e.getKey());
            d.setSize(e.getSize());
            return d;
        }
    }

    public static List<Part> getDtos(List<PartEntity> es) {
        if (es == null) {
            return null;
        } else {
            List<Part> ds = new ArrayList<Part>();
            for (PartEntity e : es) {
                ds.add(getDto(e));
            }
            return ds;
        }
    }

    @Id
    private String id;

    private String revisionId;

    private int    index;

    // TODO del
    private String key;

    private String eTag;

    private long   size;

    public long getSize() {
        return size;
    }

    public void setSize(long size) {
        this.size = size;
    }

    public int getIndex() {
        return index;
    }

    public void setIndex(int index) {
        this.index = index;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public String getETag() {
        return eTag;
    }

    public void setETag(String eTag) {
        this.eTag = eTag;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getRevisionId() {
        return revisionId;
    }

    public void setRevisionId(String revisionId) {
        this.revisionId = revisionId;
    }
}
